<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps({
  name: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: ''
  }
})
const iconName = computed(() => `#icon-${props.name}`)
const svgClass = computed(() => {
  if (props.name) return `svg-icon icon-${props.name}`
  return 'svg-icon'
})
</script>

<template>
  <svg :class="svgClass" :style="{ color: color }">
    <use :xlink:href="iconName" />
  </svg>
</template>

<style scoped>
.svg-icon {
  fill: currentColor;
  vertical-align: middle;
}
</style>
